﻿'use strict';

app.factory('articlesData', function ($resource, $q) {
    var resource = $resource('/api/articles/:id', { id: '@id' });
    return {
        getById: function(id) {
            var defer = $q.defer();
            resource.get({ id: id },
                function(article) {
                    defer.resolve(article);
                },
                function(responce) {
                    defer.reject(responce);
                });
            return defer.promise;
        }
    };
});